/**
 * Copyright (c) 2006-2007, Siemens EPM All rights reserved.
 * SIEMENS PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 *
 * Copyright (c) 2006-2007, Siemens EPM Todos os direitos reservados.
 * SIEMENS PROPRIET�RIO/CONFIDENCIAL. O uso est� sujeito aos termos de licen�a.
 */

package br.com.hstar.client;

import br.com.hstar.client.cliente.cartaofidelidade.CartaoFidelidadeService;
import br.com.hstar.client.cliente.cartaofidelidade.CartaoFidelidadeServiceAsync;
import br.com.hstar.client.cliente.cheque.ChequeService;
import br.com.hstar.client.cliente.cheque.ChequeServiceAsync;
import br.com.hstar.client.cliente.cliente.ClienteService;
import br.com.hstar.client.cliente.cliente.ClienteServiceAsync;
import br.com.hstar.client.cliente.tipocliente.TipoClienteService;
import br.com.hstar.client.cliente.tipocliente.TipoClienteServiceAsync;
import br.com.hstar.client.config.CadQuartoService;
import br.com.hstar.client.config.CadQuartoServiceAsync;
import br.com.hstar.client.formapgto.FormaPgtoService;
import br.com.hstar.client.formapgto.FormaPgtoServiceAsync;
import br.com.hstar.client.fornecedor.FornecedorService;
import br.com.hstar.client.fornecedor.FornecedorServiceAsync;
import br.com.hstar.client.funcionario.funcao.FuncaoService;
import br.com.hstar.client.funcionario.funcao.FuncaoServiceAsync;
import br.com.hstar.client.funcionario.funcionario.FuncionarioService;
import br.com.hstar.client.funcionario.funcionario.FuncionarioServiceAsync;
import br.com.hstar.client.patrimonio.PatrimonioService;
import br.com.hstar.client.patrimonio.PatrimonioServiceAsync;
import br.com.hstar.client.produto.centrocusto.CentroCustoService;
import br.com.hstar.client.produto.centrocusto.CentroCustoServiceAsync;
import br.com.hstar.client.produto.grupo.GrupoService;
import br.com.hstar.client.produto.grupo.GrupoServiceAsync;
import br.com.hstar.client.produto.produto.ProdutoService;
import br.com.hstar.client.produto.produto.ProdutoServiceAsync;
import br.com.hstar.client.quarto.QuartoService;
import br.com.hstar.client.quarto.QuartoServiceAsync;
import br.com.hstar.client.tabelapreco.PrecoService;
import br.com.hstar.client.tabelapreco.PrecoServiceAsync;
import br.com.hstar.client.usuario.UsuarioService;
import br.com.hstar.client.usuario.UsuarioServiceAsync;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.ServiceDefTarget;

public class ServiceFactory {


	private static CartaoFidelidadeServiceAsync cartaoFidelidadeService = null;
	private static ChequeServiceAsync 			chequeService = null;
	private static ClienteServiceAsync 			clienteService = null;
	private static TipoClienteServiceAsync 		tipoClienteService = null;
	private static FornecedorServiceAsync 		fornecedorService = null;
	private static FuncionarioServiceAsync 		funcionarioService = null;
	private static FuncaoServiceAsync 			funcaoService = null;	
	private static CentroCustoServiceAsync 		centroCustoService = null;
	private static GrupoServiceAsync 			grupoService = null;
	private static ProdutoServiceAsync 			produtoService = null;
	private static QuartoServiceAsync 			quartoService = null;
	private static CadQuartoServiceAsync 		cadQuartoService = null;
	private static PatrimonioServiceAsync 		patrimonioService = null;
	private static UsuarioServiceAsync 			usuarioService = null;
	private static PrecoServiceAsync 			precoService = null;
	private static FormaPgtoServiceAsync		formaPgtoService = null;
	
	/**
	 * Default constructor
	 */
	private ServiceFactory() {
		super();
	}
	
	public static CartaoFidelidadeServiceAsync createCartaoFidelidadeService() {
		if ( cartaoFidelidadeService == null ) {
			Object instance = GWT.create(CartaoFidelidadeService.class);
			cartaoFidelidadeService = (CartaoFidelidadeServiceAsync)createService( instance, "cartaoFidelidadeService");
		}
		return cartaoFidelidadeService;
	}
	
	public static ChequeServiceAsync createChequeService() {
		if ( chequeService == null ) {
			Object instance = GWT.create(ChequeService.class);
			chequeService = (ChequeServiceAsync)createService( instance, "chequeService");
		}
		return chequeService;
	}
	
	public static FormaPgtoServiceAsync createFormaPgtoService() {
		if ( formaPgtoService == null ) {
			Object instance = GWT.create(FormaPgtoService.class);
			formaPgtoService = (FormaPgtoServiceAsync)createService( instance, "formaPgtoService");
		}
		return formaPgtoService;
	}
	
	public static PatrimonioServiceAsync createPatrimonioService() {
		if ( patrimonioService == null ) {
			Object instance = GWT.create(PatrimonioService.class);
			patrimonioService = (PatrimonioServiceAsync)createService( instance, "patrimonioService");
		}
		return patrimonioService;
	}
	
	public static PrecoServiceAsync createPrecoService() {
		if ( precoService == null ) {
			Object instance = GWT.create(PrecoService.class);
			precoService = (PrecoServiceAsync)createService( instance, "precoService");
		}
		return precoService;
	}
	
	public static UsuarioServiceAsync createUsuarioService() {
		if ( usuarioService == null ) {
			Object instance = GWT.create(UsuarioService.class);
			usuarioService = (UsuarioServiceAsync)createService( instance, "usuarioService");
		}
		return usuarioService;
	}
	
	public static TipoClienteServiceAsync createTipoClienteService() {
		if ( tipoClienteService == null ) {
			Object instance = GWT.create(TipoClienteService.class);
			tipoClienteService = (TipoClienteServiceAsync)createService( instance, "tipoClienteService");
		}
		return tipoClienteService;
	}
	
	public static FornecedorServiceAsync createFornecedorService() {
		if ( fornecedorService == null ) {
			Object instance = GWT.create(FornecedorService.class);
			fornecedorService = (FornecedorServiceAsync)createService( instance, "fornecedorService");
		}
		return fornecedorService;
	}
	
	public static ClienteServiceAsync createClienteService() {
		if ( clienteService == null ) {
			Object instance = GWT.create(ClienteService.class);
			clienteService = (ClienteServiceAsync)createService( instance, "clienteService");
		}
		return clienteService;
	}
	
	public static FuncionarioServiceAsync createFuncionarioService() {
		if ( funcionarioService == null ) {
			Object instance = GWT.create(FuncionarioService.class);
			funcionarioService = (FuncionarioServiceAsync)createService( instance, "funcionarioService");
		}
		return funcionarioService;
	}
	
	public static FuncaoServiceAsync createFuncaoService() {
		if ( funcaoService == null ) {
			Object instance = GWT.create(FuncaoService.class);
			funcaoService = (FuncaoServiceAsync)createService( instance, "funcaoService");
		}
		return funcaoService;
	}
	
	public static CentroCustoServiceAsync createCentroCustoService() {
		if ( centroCustoService == null ) {
			Object instance = GWT.create(CentroCustoService.class);
			centroCustoService = (CentroCustoServiceAsync)createService( instance, "centroCustoService");
		}
		return centroCustoService;
	}
	
	public static GrupoServiceAsync createGrupoService() {
		if ( grupoService == null ) {
			Object instance = GWT.create(GrupoService.class);
			grupoService = (GrupoServiceAsync)createService( instance, "grupoService");
		}
		return grupoService;
	}
	
	public static ProdutoServiceAsync createProdutoService() {
		if ( produtoService == null ) {
			Object instance = GWT.create(ProdutoService.class);
			produtoService = (ProdutoServiceAsync)createService( instance, "produtoService");
		}
		return produtoService;
	}
	
	public static QuartoServiceAsync createQuartoService() {
		if ( quartoService == null ) {
			Object instance = GWT.create(QuartoService.class);
			quartoService = (QuartoServiceAsync)createService( instance, "quartoService");
		}
		return quartoService;
	}
	
	public static CadQuartoServiceAsync createCadQuartoService() {
		if ( cadQuartoService == null ) {
			Object instance = GWT.create(CadQuartoService.class);
			cadQuartoService = (CadQuartoServiceAsync)createService( instance, "cadQuartoService");
		}
		return cadQuartoService;
	}
	
	//-------------------------------------------------------------------------------------
	private static Object createService(Object instance, String namespace) {
        ServiceDefTarget target = (ServiceDefTarget)instance;
        target.setServiceEntryPoint(GWT.getModuleBaseURL()+ namespace);
    	return instance;
	}	
}
